package com.zj.osm.model.dao;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.zj.osm.model.pojo.ModuleType;
import com.zj.osm.utils.SQLiteDatabaseUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * author : luhenchang
 * e-mail : 1276998208@qq.com
 * time   : 2019/12/03
 * desc   :版权所有
 * version: 1.0
 */
///ModuleType表
public class ModuleTypeDao {
    private static final String SELECT_FROM_MODULE_TYPE = "select * from ModuleType mt where mt.ParentKey = '50000GT' and mt.State = '100'";
    public List<ModuleType> getModuleType() {
        List<ModuleType>moduleTypes = new ArrayList<>();
        SQLiteDatabase sqLiteDatabase = SQLiteDatabaseUtils.getInstance().getSQLiteDatabase();
        @SuppressLint("Recycle") Cursor cursor = sqLiteDatabase.rawQuery(SELECT_FROM_MODULE_TYPE, null);//此处的db是表名，name是列名
        while (cursor.moveToNext()) {
            ModuleType equip = new ModuleType();
            equip.setModuleTypeID(cursor.getString(0));
            equip.setName(cursor.getString(1));
            equip.setModuleTypeKey(cursor.getString(2));
            moduleTypes.add(equip);
        }
        cursor.close();
        return moduleTypes;
    }
}
